﻿using System;
using System.Collections.Generic;
[Serializable]
/// <summary>
///Favourites 的摘要说明
/// </summary>
public class Favourites
{
    public Favourites()
    {
        //
        //TODO: 在此处添加构造函数逻辑
        //
    }
    private List<FavItem> items = new List<FavItem>();

    public List<FavItem> Items
    {
        get { return items; }
        set { items = value; }
    }

    public bool RemoveItem(string prdtId)
    {
        for (int i = 0; i < Items.Count; i++)
        {
            if (Items[i].ItemId == prdtId)
            {
                items.RemoveAt(i);
                return true;
            }
        }
        return false;
    }
    public bool IsDuplicate(string prdtId)
    {
        for (int i = 0; i < Items.Count; i++)
        {
            if (Items[i].ItemId == prdtId)
            {
                return true;
            }
        }
        return false;
    }

    public bool AddToFav(FavItem fi)
    {
        if (!IsDuplicate(fi.ItemId))
        {
            Items.Add(fi);
            return true;
        }
        return false;
    }
}
[Serializable]
public class FavItem
{
    public FavItem()
    {
        //
        // TODO: 在此处添加构造函数逻辑
        //
    }
    public FavItem(string itemId, string itemName)
    {
        this.ItemId = itemId;
        this.ItemName = itemName;
    }

    public FavItem(string itemId, string itemName, string imgPath,decimal itemPrice)
    {
        this.ItemId = itemId;
        this.imgPath = imgPath;
        this.ItemName = itemName;
        this.ItemPrice = itemPrice;
    }

    private string itemId;

    public string ItemId
    {
        get { return itemId; }
        set { itemId = value; }
    }

    private string imgPath;

    public string ImgPath
    {
        get { return imgPath; }
        set { imgPath = value; }
    }
    private string itemName;

    public string ItemName
    {
        get { return itemName; }
        set { itemName = value; }
    }
    private decimal itemPrice;

    public decimal ItemPrice
    {
        get { return itemPrice; }
        set { itemPrice = value; }
    }
}